/**
 * 
 */
package com.chocolatefordogs.writersnb.app.project;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.MutableTreeNode;

import com.chocolatefordogs.writersnb.app.notes.NotedObjectNodeBuilder;
import com.chocolatefordogs.writersnb.app.treeutils.TreeNodeBuilder;
import com.chocolatefordogs.writersnb.core.NotedObject;
import com.chocolatefordogs.writersnb.projects.Project;

/**
 * @author Matthew
 *
 */
public final class ProjectNodeBuilder implements TreeNodeBuilder<Project> {
	
	private ProjectNodeBuilder() { }
	
	@Override
	public MutableTreeNode buildNode(final Project item) {
		final MutableTreeNode res = new DefaultMutableTreeNode(item);
		
		final MutableTreeNode notesNode = notedObjectBuilder.buildNode(item);
		
		res.insert(notesNode, res.getChildCount());
		return res;
	}
	
	public static TreeNodeBuilder<Project> getInstance() {
		return instance;
	}

	private final TreeNodeBuilder<NotedObject> notedObjectBuilder = NotedObjectNodeBuilder.getInstance();
	
	private static final ProjectNodeBuilder instance = new ProjectNodeBuilder();
}
